package ncu.me.musicplayer;

import android.app.Application;
import android.content.Context;

import ncu.me.musicplayer.entity.DaoMaster;
import ncu.me.musicplayer.entity.DaoSession;
import ncu.me.musicplayer.player.MusicManager;
import ncu.me.musicplayer.player.MusicPlayer;

/**
 * @Author ye
 * @Date 2020/6/1 21:04
 * @Version 1.0
 */
public class MyApplication extends Application {
    public static Context sAppContext;
    public static DaoSession sDaoSession;
    @Override
    public void onCreate() {
        super.onCreate();
        sAppContext = getApplicationContext();


        //初始化GreenDao
        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(getApplicationContext(),"data");
        DaoMaster master = new DaoMaster(helper.getReadableDb());
        sDaoSession = master.newSession();

        //初始化MusicManager
        MusicManager.getInstance().init(new MusicPlayer(getApplicationContext()));

    }

}
